public with sharing class ControllerForGetValue {
    
   
    public PageReference AutoCopyFn(){
    	Lead picklist = new Lead();
         Car_Owner__c co = new Car_Owner__c();
        // get param : leadid  ApexPages.currentPage().getParameters().get('leadid');

        String leadid = Apexpages.currentPage().getParameters().get('leadid');
        
        Lead lead = [SELECT ID,Address__c,Car_Brand__c,
                            Car_Type__c,Car_Unit_Price__c,City__c,Date_Of_Birth__c,
                            District__c,Gender__c,Email,Fax,MobilePhone,
                            Name,phone,Province__c FROM LEAD WHERE ID =: leadid ]; // Where ID=:leadid
        
        
        
        // set co fields
                            
        co.Address__c = lead.Address__c;
        co.Brand__c = lead.Car_Brand__c;
        co.Car_Type__c = lead.Car_Type__c;
        co.Car_Unit_Price__c = lead.Car_Unit_Price__c;
        co.City__c = lead.City__c;
        co.Date_Of_Birth__c = lead.Date_Of_Birth__c;
        co.District__c = lead.District__c;
        co.Mobile_Phone__c = lead.MobilePhone;
        co.Gender__c = lead.Gender__c;
        co.Email__c = lead.Email;
        co.Fax__c = lead.Fax;
        co.Name = lead.Name;
        co.Phone__c = lead.Phone;
        co.Province__c = lead.Province__c;
        insert co;
        
        lead.Rating = 'Closed';
        update lead;
        
        PageReference pageGoto= new Pagereference('/'+co.Id);
        
        return pageGoto;
    }
    
}